
package com.idea.rdftree.editor;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import com.idea.rdftree.RdfTreeNode;

public class NodePanel extends JPanel {

	private JLabel nodeTypeLabel;
	private RdfTreeNode rdfTreeNode;
	private JTextField nodeValueField;

	public NodePanel() {
		setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		nodeTypeLabel = new JLabel("Node Type : ");
		add(nodeTypeLabel);
	
		nodeValueField = new JTextField("None Selected.");
		nodeValueField.setBackground(RdfEditor.READ_ONLY_COLOR);
		add(nodeValueField);
	}

	public void setRdfTreeNode(RdfTreeNode rdfTreeNode) {
		this.rdfTreeNode = rdfTreeNode;
		nodeTypeLabel.setText(rdfTreeNode.getNodeTypeName());
		nodeValueField.setText(rdfTreeNode.getRdfValue());

				nodeValueField.setEditable(rdfTreeNode.isValueEditable());
				if(rdfTreeNode.isValueEditable()){
					nodeValueField.setBackground(RdfEditor.READ_WRITE_COLOR);
				}else{
					nodeValueField.setBackground(RdfEditor.READ_ONLY_COLOR);
				}
	}

}
